
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="page" />
<html>
<head>
    <title>Insert title here</title>
    <link rel="stylesheet" href="${ctx}/css/templatemo_style.css" /> <!-- 页面整体布局样式定义 -->
    <link rel="stylesheet" href="${ctx}/css/ddsmoothmenu.css" /> <!-- 菜单样式定义 -->
    <script type="text/javascript" src="${ctx}/js/jquery-1.4.3.min.js"></script>

     <script type="text/javascript">
        var ctx = "${pageContext.request.contextPath}";
        function showUserName(){
            var name = "${user.userName}";
            console.log(name);
            if(name != ""){
                $("#login").html(name);
                $("#exitP").show();
                $("#login").attr("href", ctx + "/user?flag=finduser&username=${user.userName}");
            }else{
                $("#login").html("登录");
                $("#exitP").hide();
                $("#login").attr("href", ctx + "/user?flag=lp");
            }
        }
        ////////////////////////////
        function stockcheck(product_id){

             if("${user.userName}"!="")
                {
                    $.get(
                        "${ctx}/product?flag=add",
                        {"productId":product_id,"quantity":"1","user_id":"${user.userId}"},
                        function(data){
                            if(parseInt(data)>0)
                            {
                                alert("添加成功");
                            }
                            else
                            {
                                alert("添加失败");
                            }
                        },
                        "text"
                    );
                }
                else
                {
                    alert("请登录");
                }
        }
        function gotopage(pageno, pages) { // pageno查询的页数; pages总页数
            if (pageno == 0) {
                pageno = 1;
            }
            if (pageno > pages) {
                pageno = pages;
            }
            $("#pageNo").val(pageno);
            $("#profy").submit();
        }
    </script>
</head>

<body>
<div id="templatemo_body_wrapper">
    <div id="templatemo_wrapper">


        <!-- header -->
        <div id="templatemo_header">
            <div id="site_title"><h1><a href="${ctx}/home">穿美在线鞋城</a></h1></div>
            <div id="header_right">
                <p>
                    <a href="${ctx}/user?flag=lp" id="login">登录</a>&nbsp;
                    <span id="exitP" style="display: none"><a href="${ctx}/user?flag=logout" id="exit">注销</a></span>
                </p>
            </div>
            <div class="cleaner"></div>
        </div>
        <!-- END of templatemo_header -->


        <!-- menu -->
        <div id="templatemo_menubar">
            <div id="top_nav" class="ddsmoothmenu">
                <ul>
                    <li><a href="${ctx}/home">首页</a></li>
                    <li><a href="${ctx}/product" class="selected">产品</a></li>
                    <li><a href="${ctx}/shopcart?userId=${sessionScope.user.userId}">我的购物车</a></li>
                    <li><a href="${ctx}/order">我的订单</a></li>
                </ul>
                <br style="clear: left" />
            </div>
            <!-- end of ddsmoothmenu -->
        </div>
        <!-- END of templatemo_menubar -->


        <!-- main -->
        <div id="templatemo_main">
            <!-- 侧边栏 -->
            <div id="sidebar" class="float_l">
                <!-- sidebar 1 -->
                <div class="sidebar_box">
                    <span class="bottom"></span>
                    <h3>品牌</h3>
                    <div class="content">
                        <ul class="sidebar_list">
                            <c:forEach items="${requestScope.category}" var="gory" >
                                <li><a href="${ctx}/product?categoryId=${gory.categoryId}">${gory.name}</a></li>
                            </c:forEach>
                        </ul>
                    </div>
                </div>
                <!-- sidebar 2 -->
                <div class="sidebar_box">
                    <span class="bottom"></span>
                    <h3>热卖单品</h3>
                    <div class="content">

                      <!--  <div class="bs_box">
                            <a href="javascript:void(0);"><img src='${ctx}/images/product/10.jpg' alt="image" style="width: 62px; height: 72px" /></a>
                            <p>特步 红色 运动鞋</p>
                            <p class="price">￥480.0</p>
                            <div class="cleaner"></div>
                        </div>

                        <div class="bs_box">
                            <a href="javascript:void(0);"><img src='${ctx}/images/product/17.jpg' alt="image" style="width: 62px; height: 72px" /></a>
                            <p>阿迪达斯 黑色 帆布鞋</p>
                            <p class="price">￥320.0</p>
                            <div class="cleaner"></div>
                        </div>

                        <div class="bs_box">
                            <a href="javascript:void(0);"><img src='${ctx}/images/product/15.jpg' alt="image" style="width: 62px; height: 72px" /></a>
                            <p>新百伦 天蓝 运动鞋</p>
                            <p class="price">￥260.0</p>
                            <div class="cleaner"></div>
                        </div>-->
                        <c:forEach items="${requestScope.hot}" var="hot_v">
                           <div class="bs_box">
                              <!--  <a href="javascript:hotmai(${hot_v.productId});"><img src='${ctx}/${hot_v.imgpath}' alt="image" style="width:62px;height:72px"/></a>-->
                                 <a href="${ctx}/product?productId=${hot_v.productId}&flag=d"><img src='${ctx}/${hot_v.imgpath}' alt="image" style="width:62px;height:72px"/></a>
                                <p>${hot_v.feature}</p>
                                <p class="price">￥${hot_v.price}</p>
                                <div class="cleaner"></div>
                            </div> -
                        </c:forEach>

                    </div>
                </div>
            </div>
            <!-- END of sidebar -->

            <!-- 内容展示区 -->
            <div id="content" class="float_r">
                <!-- 商品列表展示  -->
                <h3 >
                    品牌：
                    ${requestScope.category_name}
                </h3>

                  <c:forEach items='${requestScope.pageinfo.getObjs()}' var="pd">
                      <div class="product_box">
                        <a href="${ctx}/product?productId=${pd.productId}&flag=d"><img src='${ctx}/${pd.imgpath}' alt="Shoes 2" /></a>
                          <p>${pd.feature}</p>
                          <p class="product_price">￥${pd.price}</p>
                       <a href='javascript:stockcheck("${pd.productId}");' class="addtocart"></a>
                        <a href="${ctx}/product?productId=${pd.productId}&flag=d" class="detail">

                          </a>
                      </div>
                  </c:forEach>
            </div>

            <div class="product_box_fy">
                <p>
                    <a href="${ctx}/product?pageNo=1&pageSize=3&categoryId=${requestScope.category_id}">首页</a> |
                    <a href="${ctx}/product?pageNo=${requestScope.pageinfo.pageNo}&pageSize=3&zt=up&categoryId=${requestScope.category_id}">上一页</a> |

                    <a href="${ctx}">每页&nbsp;<input type="text" id="ps" name="ps" value="6" maxlength="2" style="width: 18px; height: 12px; text-align: center;">&nbsp;条数据 </a> |
                    <a href="${ctx}">第${requestScope.pageinfo.pageNo}页/共${requestScope.pageinfo.pages}页</a> |

                    <a href="${ctx}product?pageNo=${requestScope.pageinfo.pageNo}&pageSize=3&zt=next&pages=${requestScope.pageinfo.pages}&categoryId=${requestScope.category_id}">下一页</a> |
                    <a href="${ctx}/product?pageNo=${requestScope.pageinfo.pages}&pageSize=3&categoryId=${requestScope.category_id}">尾页</a>
                </p>
            </div>

            <div class="cleaner"></div>
        </div>
        <!-- END of templatemo_main -->


        <!-- footer -->
        <div id="templatemo_footer">
            <p>
                <a href="${ctx}/home">首页</a> | <a href="${ctx}/product">产品</a> | <a href="${ctx}/shopcart">我的购物车</a> | <a href="${ctx}/order">我的订单</a>
            </p>
            版权所有 (c) 2018 <a href="javascript:void(0);">金桥软件</a>
        </div>
        <!-- END of templatemo_footer -->


    </div>
    <!-- END of templatemo_wrapper -->
</div>
<!-- END of templatemo_body_wrapper -->
<script type="text/javascript">
    $(function(){
        showUserName();
    });
</script>
</body>
</html>
